from selenium import webdriver
import time

driver = webdriver.Chrome()
driver.implicitly_wait(5)
driver.get("http://192.168.2.155:8080/woniusales/")  #发送访问WoniuSales的请求
time.sleep(2)
assert driver.find_element_by_xpath("//div[1]/div[1]/div[1]/div[1]").is_displayed()  #断言是否进入蜗牛进销存登录页面

time.sleep(1)
driver.find_element_by_id("username").clear()
driver.find_element_by_id("username").send_keys("admin")   #输入用户名
time.sleep(1)
driver.find_element_by_id("password").clear()
driver.find_element_by_id("password").send_keys("admin")  #输入密码
time.sleep(1)
driver.find_element_by_id("verifycode").clear()
driver.find_element_by_id("verifycode").send_keys("")     #输入验证码
time.sleep(1)
driver.find_element_by_xpath("//html/body/div[4]/div/form/div[6]/button").click()  #点击登录
time.sleep(1)

try:
    actural = driver.find_element_by_class_name("bootbox-body").text        #获取登录后提示语
    print(actural)
    expect = "验证码失效，请重新输入."
    if expect in actural:      #断言登录结果是否正确
        print("test006验证通过.")
except:
    print("test006验证失败.")